import pandas as pd
import numpy as np

def kFord(k,data,seed):
    '''
    函数名称：K折划分
    :param k: 划分集合数
    :param data: 待划分数据
    :return: 已划分数据
    '''
    split_data={}
    #step - 打乱顺序
    for key in data.keys():
        np.random.seed(seed) #设定相同的种子，保持各子data洗牌的匹配
        np.random.shuffle(data[key])
        split_data[key]=[]
        batch_size=int(data[key].shape[0]/k)
        for i in range(k):
            if i!=k-1:
                split_data[key].append(data[key][i*batch_size:(i+1)*batch_size])
            else:
                split_data[key].append(data[key][i * batch_size:])
    return split_data
